home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / tchrt3.zip / SEEKTEST.C < prev    next >
Text File  |  1990-07-23  |  19KB  |  430 lines

  1. /*---------------------------------------------------------------------------
  2.  |  Program SEEKTEST.C                                                      |
  3.  |                                                                          |
  4.  |  This program demonstrates the use of TCHRT in timing seek performance   |
  5.  |  of a PC based hard disk drive.  The method used will determine the total|
  6.  |  seek time of the device which includes actual disk seek, controller     |
  7.  |  overhead, and ROM BIOS overhead.  This is a "real world" measurement    |
  8.  |  of disk performance under actual usage conditions.                      |
  9.  |                                                                          |
  10.  |  This program uses both inline generic timers and BIOS interrupt         |
  11.  |  timers to measure disk performance.                                     |
  12.  |                                                                          |
  13.  |  (c)1989 Ryle Design, P.O. Box 22, Mt. Pleasant, Michigan 48804          |
  14.  |                                                                          |
  15.  |  V3.00  Turbo C Shareware Evaluation Version                             |
  16.  ---------------------------------------------------------------------------*/
  17.  
  18. #include <stdio.h>
  19. #include <conio.h>
  20. #include <dos.h>
  21. #include <process.h>
  22.  
  23. #include "pchrt.h"
  24.  
  25. union REGS      inregs,outregs;
  26.  
  27. long unsigned   seek1, seek2, hits1, hits2, seek3, hits3;
  28.  
  29.  
  30. void disk_err(int istat)
  31. /*---------------------------------------------------------------------------
  32.  |  This procedure outputs a description of an INT 13h error status, and    |
  33.  |  halts program exection.                                                 |
  34.  |                                                                          |
  35.  |  Globals referenced: none                                                |
  36.  |                                                                          |
  37.  |  Arguments: (int) istat - status returned from INT 13h in AX if carry    |
  38.  |                           flag set.                                      |
  39.  |                                                                          |
  40.  |  Returns  : void                                                         |
  41.  ---------------------------------------------------------------------------*/
  42. {
  43.     switch (istat)
  44.     {
  45.         case 0x00 : return;                                    /* no error */
  46.  
  47.         case 0x01 : printf("Disk error: Invalid command\n");
  48.                     break;
  49.  
  50.         case 0x02 : printf("Disk error: Address mark not found\n");
  51.                     break;
  52.  
  53.         case 0x03 : printf("Disk error: Disk is write-protected\n");
  54.                     break;
  55.  
  56.         case 0x04 : printf("Disk error: Requested sector not found\n");
  57.                     break;
  58.  
  59.         case 0x05 : printf("Disk error: Reset failed\n");
  60.                     break;
  61.  
  62.         case 0x06 : printf("Disk error: Floppy disk removed\n");
  63.                     break;
  64.  
  65.         case 0x07 : printf("Disk error: Bad parameter table\n");
  66.                     break;
  67.  
  68.         case 0x08 : printf("Disk error: DMA overrun\n");
  69.                     break;
  70.  
  71.         case 0x09 : printf("Disk error: DMA crossed 64KB boundary\n");
  72.                     break;
  73.  
  74.         case 0x0A : printf("Disk error: Bad sector flag set\n");
  75.                     break;
  76.  
  77.         case 0x0B : printf("Disk error: Bad track flag set\n");
  78.                     break;
  79.  
  80.         case 0x0C : printf("Disk error: Requested media type not found\n");
  81.                     break;
  82.  
  83.         case 0x0D : printf("Disk error: Invalid number of sectors on format\n");
  84.                     break;
  85.  
  86.         case 0x0E : printf("Disk error: Control data address mark detected\n");
  87.                     break;
  88.  
  89.         case 0x0F : printf("Disk error: DMA arbitration level out of range\n");
  90.                     break;
  91.  
  92.         case 0x10 : printf("Disk error: Uncorrectable CRC or ECC data error\n");
  93.                     break;
  94.  
  95.         case 0x11 : printf("Disk warning: ECC corrected data error\n");
  96.                     return;
  97.  
  98.         case 0x20 : printf("Disk error: Controller failed\n");
  99.                     break;
  100.  
  101.         case 0x40 : printf("Disk error: Seek failed\n");
  102.                     break;
  103.  
  104.         case 0x80 : printf("Disk error: Disk has timed out\n");
  105.                     break;
  106.  
  107.         case 0xAA : printf("Disk error: Drive not ready\n");
  108.                     break;
  109.  
  110.         case 0xBB : printf("Disk error: Error is undefined\n");
  111.                     break;
  112.  
  113.         case 0xCC : printf("Disk error: Write fault\n");
  114.                     break;
  115.  
  116.         case 0xE0 : printf("Disk error: Status register error\n");
  117.                     break;
  118.  
  119.         case 0xFF : printf("Disk error: Sense operation failed\n");
  120.                     break;
  121.  
  122.         default   : printf("Unknown INT 13 return status %d\n",istat);
  123.                     break;
  124.     }
  125.  
  126.     exit(1);
  127.  
  128. } /* disk_err */
  129.  
  130.  
  131. void test_disk(char disk)
  132. /*---------------------------------------------------------------------------
  133.  |  This function, which contains the actual disk test routines, does the   |
  134.  |  following:                                                              |
  135.  |      1. Seeks the test disk to track 0.                                  |
  136.  |      2. Times 100 calls to seek to track 0.  Since the heads are already |
  137.  |         on track 0, they will not move, and a estimate of the software   |
  138.  |         overhead for each seek call can be made.                         |
  139.  |      3. Times single track seeks to all cylinders (0-1,1-2,2-3,3-4,etc). |
  140.  |         This provides a measurement of single track seek time.           |
  141.  |      4. Seeks from track 0 to all tracks (0-1,0-2,0-3,0-4,etc).  This    |
  142.  |         provides average seek time for the entire disk.                  |
  143.  |      5. The results are reported.                                        |
  144.  |                                                                          |
  145.  |  int86() is used to call the ROM BIOS.  There is some software           |
  146.  |  overhead incurred using this method.                                    |
  147.  |                                                                          |
  148.  |  Generic inline timers are used to measure disk performance.             |
  149.  |                                                                          |
  150.  |  Globals referenced: inregs, outregs.                                    |
  151.  |                                                                          |
  152.  |  Arguments: (char) disk - physical disk # - add to 0x80 for BIOS call.   |
  153.  |                                                                          |
  154.  |  Returns  : void                                                         |
  155.  ---------------------------------------------------------------------------*/
  156. {
  157.     
  158.     int             maxhead,maxcyl,indx;
  159.     unsigned long   seek1,seek2,seek3,hits1,hits2,hits3;
  160.     
  161.     inregs.h.dl = 0x80 + disk;                              /* get disk config */
  162.     inregs.h.ah = 0x08;
  163.     int86(0x13,&inregs,&outregs);
  164.     if (outregs.x.cflag != 0) disk_err(outregs.h.ah);
  165.  
  166.     maxhead = outregs.h.dh;                                 /* move bits to get */
  167.     maxcyl = ((outregs.h.cl & 0xC0) << 2) + outregs.h.ch;   /* heads & tracks   */
  168.  
  169.     printf("\nPhysical drive %d shows %d cylinders, %d heads\n\n",disk,maxcyl+1,maxhead+1);
  170.  
  171.     printf("Starting single track seek test ...\n");
  172.  
  173.     inregs.h.ah = 0x0C;                                     /* seek command                        */
  174.     inregs.h.ch = 0x00;                                     /* track 0                             */
  175.     inregs.h.cl = 0x01;                                     /* XTs need sector bit set, or no seek */
  176.     inregs.h.dh = 0;                                        /* head 0                              */
  177.     inregs.h.dl = 0x80 + disk;                              /* disk #                              */
  178.  
  179.     int86(0x13,&inregs,&outreg